package com.itheima.health.controller.admin;

import com.aliyuncs.http.HttpResponse;
import com.itheima.health.common.MessageConst;
import com.itheima.health.dto.BusinessData;
import com.itheima.health.dto.MemberReportParam;
import com.itheima.health.dto.SetmealReportParam;
import com.itheima.health.result.Result;
import com.itheima.health.service.CountingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/report")
@Slf4j
/*
* 数据统计
* */
public class countingController {
    @Autowired
    private CountingService  countingService;
    /*
    * 统计会员数量
    * */
    @GetMapping("/getMemberReport")
    public Result getMemberReport(){
       MemberReportParam m  = countingService.getMemberReport();
        return new Result(true, MessageConst.GET_MEMBER_NUMBER_REPORT_SUCCESS,m);
    }

    /*
    * 套餐占比
    * */
    @GetMapping("/getSetmealReport")
    public Result getSetmealReport(){
     SetmealReportParam setmealReport =  countingService.getSetmealReport();
     return new Result(true,MessageConst.GET_SETMEAL_COUNT_REPORT_SUCCESS,setmealReport);
    }
    /*
    * 查询运营数据
    * */
    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData(){
       BusinessData businessData = countingService.getbusinessRepor();
       return  new Result(true,MessageConst.GET_BUSINESS_REPORT_SUCCESS,businessData);
    }
        /*
        * 导出elxs表
        * */
    @GetMapping("/exportBusinessReport")
    public void export(HttpServletResponse response){
            countingService.export(response);
    }
}
